﻿// See https://aka.ms/new-console-template for more information
using System;
using System.Threading;

class Clock
{
    public event Action Tick = delegate { };
    public event Action Alarm = delegate { };

    public void Start(int alarmTime)
    {
        for (int i = 0; i <= alarmTime; i++)
        {
            Thread.Sleep(1000); 
            Console.WriteLine("Tick");
            Tick();

            if (i == alarmTime)
            {
                Console.WriteLine("Alarm!");
                Alarm();
                break;
            }
        }
    }
}

class Program
{
    static void Main()
    {
        var clock = new Clock();

       
        clock.Tick += () => Console.WriteLine("闹钟正在嘀嗒。");

        
        clock.Alarm += () => Console.WriteLine("闹钟响了！");
        int num = Convert.ToInt32(Console.ReadLine());

        clock.Start(num);
        Console.WriteLine("请输入时间");
        Console.ReadLine();
    }
}
